package com.flute.haflute.web;

import java.util.List;

import com.flute.haflute.agent.job.JobContextInstaller;
import com.flute.haflute.agent.job.JobResourceManager;
import com.flute.haflute.agent.manage.ClusterResourceCenter;
import com.flute.haflute.agent.topo.Node;

public class JobService4Web {
	
   public static int getAllFreeNodes(){
	   List<Node> allfreenodes = JobResourceManager.getInstance().getAllFreeNodes();
	   return allfreenodes.size();
   }
   /**
    * 
    * @param nodecheck 对应单选 任务属性
    * @param checkval  对于任务所对应的值（目前只存在选择 appoint时候有-）
    */
   public static boolean setNodeCheck4Web(String nodecheck,String checkval){
	   try{
		   JobContextInstaller.setAppointval(Integer.valueOf(checkval));
		   JobContextInstaller.setNodeChecked(nodecheck); 
		   return true;
	   }catch(Exception e){
		   return false;
	   }
   }

   public static void endJobByJobMaster(String controllerIp) {
	   ClusterResourceCenter.endJobManually(new Node(controllerIp));
   }
}
